#include"processBar.h"
#include<unistd.h>

typedef void (*callback_t)(int);

//模拟一种安装或者下载环境
void download(callback_t cb)
{
    int total=10000;
    int curr=0;
    while(curr<=total)
    {
        //更新进度
        int rate=curr*100/total;

        //通过回调展示进度
        cb(rate);

        //表下载的一部分
        curr+=10;
        usleep(10000);
    }

    printf("\n");
}

int main()
{
    printf("download1:\n");
    download(processbar);
    initBar();
    
    printf("download2:\n");
    download(processbar);
    initBar();

    printf("download3:\n");
    download(processbar);
    initBar();

    printf("download4:\n");
    download(processbar);
    initBar();

    return 0;
}
